<?php 
define('IN_QY',true);
session_start();
require("include/common.inc.php");
require('include/functions.php');
header("Content-type: text/html; charset=utf-8");
define('SCRIPT','ad_list');
if(!$_COOKIE['userid']){
    echo "<script type='text/javascript'>location.href='mlogin.php';</script>";
    exit;
}

$sqlusm = "select * from tbl_shiming where userid=".$_COOKIE['userid'];
$queryusm=mysql_query($sqlusm);
$rowusm=mysql_fetch_array($queryusm);
$weishim = $rowusm['tupian'];
if(!$rowusm){
    echo "<script type='text/javascript'>alert('请先实名认证,再发布.');location.href='shiming.php';</script>";
    exit;
}


?> 
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>闲置发布-众晒网</title>
    <link href="/ui/css/Hui.css" rel="stylesheet" type="text/css"/>             
    <script src="/ui/js/jquery-1.9.1.min.js"></script>
    <script src="/ui/plugins/swiper/swiper.min.js"></script>
	<script type="text/javascript" src="/ui/layer/mobile/layer.js"></script> 
    <style type="text/css">
     tr{border-bottom:1px solid #EDEDED}
.layui-tab{-5px 0px 45px 0px;text-align:left!important}
::-webkit-scrollbar { display: none;}   /*隐藏右边滚动条*/
        #header{width:100%; position:absolute; top:0;}                /*顶部定位*/
        #main{width:100%; overflow: auto; position:absolute; top:45px;bottom:0px;}
    </style>  
    <style>
	#feedback{width:60px;margin:0 auto;}
	#feedback img{width:60px;height:60px;padding: 5px;box-shadow: 0 0 5px #ccc;border-radius: 5px;}
	.H-width-avg-4 {
    width: 100%;
	}
	select#sheng {
    border: 0px;
    margin-right: 196px;
    width: 55%;
	}
    select#shi {
    border: 0px;
    }
    select#qu {
    border: 0px;
    }
	.H-flex-item.H-padding-horizontal-both-10.H-font-size-16.H-padding-vertical-both-12 {
    height: 45px;
	}
	span {
    margin-top: -5px;
	}
	button.H-button.H-width-100-percent.H-font-size-18.H-outline-none.H-padding-vertical-both-8.H-padding-horizontal-both-17.H-theme-background-color8.H-theme-font-color-white.H-theme-border-color8.H-theme-border-color8-click.H-theme-background-color8-click.H-theme-font-color8-click.H-border-radius-3 {
    margin-top: 15px;
	}
	.H-margin-horizontal-both-10 {
    margin-left: 0px;
    width: 100%;
    margin-right: 10px;
	}
	.H-theme-background-color8 {
    background-color: #f26c27;
}
input#thegujia {
    margin-top: -6px;
}
select#shi {
    border: 0px;
    width: 122%;
}
select#sheng {
    border: 0px;
    margin-right: 196px;
    width: 55%;
}
</style>      
</head>
<body ">
    <header class="H-header H-theme-background-color-white" id="header">
        <span tapmode="" onclick="window.location.href='main.php'" class="H-icon H-position-relative H-display-inline-block H-float-left H-vertical-middle H-theme-font-color8 H-padding-horizontal-left-10 H-z-index-100"><label class="H-display-block H-vertical-middle H-font-size-15"><img src="/ui/image/发布取消叉@3x.png" style="width: 15px; height: 15px; margin-top: 15px; margin-left: 10px;"></label></span>
        <div class="H-header-title H-center-all H-font-size-18 H-text-show-row-1 H-theme-font-color-black H-position-absolute H-width-100-percent">闲置发布</div>
    </header>
    <div id="main">  
       <div class="H-horizontal-center  H-overflow-hidden" style="min-height: 80px;">
            <div style="margin-left:10px;width:50px;height:83px" onclick="getElementById('inputfile').click()">
            <div style="float:left; height: 83px;">
            <img src="/ui/image/相机 -4.png"  style="margin-top:15px;width:50px;height:48px" alt="" title="添加照片">
            <input type="file" accept="image/*" multiple="multiple" id="inputfile" style="height:0;width:0;z-index: -1; position: absolute;left: 10px;top: -100px;"/>
            <span style="font-size:12px">添加照片</span>
            </div>
            </div>
        </div>
		
    <div class="H-padding-vertical-bottom-10"></div>
    <div class="H-clear-both H-width-1-percent H-display-table H-box-sizing-border-box H-padding-horizontal-left-5">
        <div class="H-display-table-cell H-float-left  H-box-sizing-border-box H-width-avg-4 H-padding-horizontal-right-5 H-margin-vertical-bottom-5">
           
            <div  style="width:100%"  id="feedback"  value="feedback" name="ywyuedu" >
			
            <input style=" display:none" id="srcall" name="ywyuedu">
			 <input type="hidden" id="lat" name="lat">
			 <input type="hidden" id="lng" name="lng">
        </div>

    </div>
    <div class="H-padding-vertical-bottom-10"></div>

 </div>


    
    <div class="H-padding-vertical-bottom-2"></div>
    <div class="H-flexbox-horizontal H-theme-background-color-white H-margin-vertical-bottom-2">
        <input type="text" name="title" id="chtitle" class="H-textbox H-vertical-align-middle H-vertical-middle H-font-size-16 H-flex-item H-box-sizing-border-box H-border-none H-outline-none H-padding-12" placeholder="商品名称">
    </div>    
    <div class="H-flexbox-horizontal">
        <textarea name="ziwop" id="ziwop" class="H-textbox H-vertical-align-middle H-vertical-middle H-font-size-12 H-flex-item H-box-sizing-border-box H-border-none H-outline-none H-padding-12" placeholder="请输入商品规格，配置参数等内容。"></textarea>
    </div>

    <div class="H-text-list H-flexbox-horizontal  H-theme-background-color-white H-border-vertical-bottom-after H-vertical-middle H-touch-active">
        <span class="H-icon H-display-block H-margin-horizontal-left-10"><i class="H-iconfont H-icon-position H-font-size-18 H-vertical-middle H-theme-font-color-ccc"></i></span>
        <input type="text" style="display: none;" class="mui-input-clear" id="cityResult5" name="shoparea"/>
        <div  class=" H-flex-item H-padding-horizontal-both-8 H-font-size-12 H-padding-vertical-both-10 H-theme-font-color-444">当前城市</div>
        <div id="cityy" style="margin-right:70px"></div>
<!----id="showCityPicker"-------
        <span class="H-display-block H-font-size-12  H-theme-font-color-999">全新宝贝</span>
        <input type="checkbox" checked="checked" name="new" class="H-checkbox H-checkbox-null H-vertical-align-middle H-margin-horizontal-right-15 H-font-size-18 H-theme-font-color1 H-theme-background-color-white H-border-radius-circle">
   ------------------>
    </div>
            <div class="H-flexbox-horizontal H-clear-both H-theme-background-color-white H-padding-8 H-box-sizing-border-box H-border-vertical-top-margin-both-10-after">
			  <span class="H-font-size-14 H-flex-item  H-center-all H-theme-font-color9 H-border-horizontal-right-after"><label class="H-display-inline-block H-vertical-middle"> 
			  商品分类
			  </span>
                <span class="H-font-size-14 H-flex-item  H-center-all H-theme-font-color9 H-border-horizontal-right-after"><label class="H-display-inline-block H-vertical-middle"> 
				<select name="fenlei"  id="sheng" style="width=25%" >
                  <option value ="0">商品分类</option>
                <?php 
                    $sql_cat = "select * from tbl_specifa where type=2 and status=0 and pid=0 order by id asc";
                    $query_cat = mysql_query($sql_cat);
                    while ($row_cat=mysql_fetch_array($query_cat)) { 
                ?> 
                    <option value ="<?php echo $row_cat['id']; ?>"><?php echo $row_cat['spe_val']; ?></option>
                <?php } ?>
                  </select></label></span>
                <span class="H-font-size-14 H-flex-item  H-center-all"><label class="H-display-inline-block H-theme-font-color-ccc H-vertical-middle">
				<select  id="shi" name="fenlei1" >
                    <option value="0">二级分类</option>
                  </select>
                   </label></span>

            </div>
     <div class="H-padding-vertical-bottom-2"></div>
    <div class="H-margin-horizontal-both-10 H-theme-border-color-eee H-border-radius-5 H-overflow-hidden H-margin-vertical-top-10">
        <div class="H-accordion-area">
            <div class="H-accordion-title H-text-list H-flexbox-horizontal  H-theme-background-color-white H-border-vertical-bottom-after H-vertical-middle H-touch-active">
                <div class="H-flex-item H-padding-horizontal-both-10 H-font-size-16 H-padding-vertical-both-12">服务收费<span style="float:right">
					<p style="margin-top:6px ;float: right; margin-right:9px;">元</p>
                <input type="number" name="shoujia" id= "thegujia" min="1"  class="H-textbox H-vertical-align-middle H-vertical-middle H-font-size-8 H-box-sizing-border-box H-border-none H-outline-none H-padding-10"  style="width:auto; float: right; text-align: right;"></div>
                
            </div>
            <div class="H-accordion-main H-padding-vertical-top-10 H-theme-background-color-white H-border-vertical-bottom-after H-display-none-important">
                <div class="H-clear-both H-width-100-percent H-display-table H-box-sizing-border-box H-padding-horizontal-left-10">
       
                </div>
            </div>
        </div>
    </div>

	     <div class="H-padding-vertical-bottom-2"></div>
    <div class="H-margin-horizontal-both-10 H-theme-border-color-eee H-border-radius-5 H-overflow-hidden H-margin-vertical-top-10">
        <div class="H-accordion-area">
            <div class="H-accordion-title H-text-list H-flexbox-horizontal  H-theme-background-color-white H-border-vertical-bottom-after H-vertical-middle H-touch-active">
                <div class="H-flex-item H-padding-horizontal-both-10 H-font-size-16 H-padding-vertical-both-12">输入运费<span style="float:right">
					<p style="margin-top:6px ;float: right; margin-right:9px;">元</p>
                <input type="number" name="diy_delivery_money" id= "diy_delivery_money" min="1"  class="H-textbox H-vertical-align-middle H-vertical-middle H-font-size-8 H-box-sizing-border-box H-border-none H-outline-none H-padding-10"  style="width:auto; float: right; text-align: right;"></div>
                
            </div>
            <div class="H-accordion-main H-padding-vertical-top-10 H-theme-background-color-white H-border-vertical-bottom-after H-display-none-important">
                <div class="H-clear-both H-width-100-percent H-display-table H-box-sizing-border-box H-padding-horizontal-left-10">
       
                </div>
            </div>
        </div>
    </div>
	
    <center>  
    <button type="button" onclick="clicimg()" class="H-button H-width-100-percent H-font-size-18 H-outline-none H-padding-vertical-both-8 H-padding-horizontal-both-17 H-theme-background-color8 H-theme-font-color-white H-theme-border-color8 H-theme-border-color8-click H-theme-background-color8-click H-theme-font-color8-click H-border-radius-3" style="width:95%">确认发布</button>
    </center>
       <div class="H-padding-vertical-bottom-2"></div> 
        
 
     </div>
    <script src="/ui/script/H.js" type="text/javascript"></script>
	
       <script>  
        if (navigator.geolocation){  

            navigator.geolocation.getCurrentPosition(  

                function( position ) {    

                    show_msg( position );  

                 },  

                function( err ) {  

                    switch(error.code){  
                    case 0:  
                      alert("尝试获取您的位置信息时发生错误：" + error.message);  
                      break;  
                    case 1:  
                        alert("用户拒绝了获取位置信息请求。");  
                      break;  
                    case 2:  
                        alert("浏览器无法获取您的位置信息：" + error.message);  
                      break;  
                    case 3:  
                        alert("获取您位置信息超时。");  
                      break;  
                    }  
                }  
       )}else  
          alert( '您当前使用的浏览器不支持Geolocation服务' );  


        function show_msg( position ){  

            var lat = position.coords.latitude;

            var lng = position.coords.longitude; 
            $("#lat").val(lat);
			$("#lng").val(lng);
			
           // alert( "您所在的位置： 经度" +  + "，纬度" + lng );  
            if( typeof position.address != "undefined" ){  

                var country = position.address.country; 

                var province = position.address.region;

                var city = position.address.city;  

               // alert(' 您位于 ' + country + province + '省' + city +'市');  
            }  
			
			  var latlon = position.coords.latitude+','+position.coords.longitude; 
 
  //baidu
  var url = "http://api.map.baidu.com/geocoder/v2/?ak=C93b5178d7a8ebdb830b9b557abce78b&callback=renderReverse&location="+latlon+"&output=json&pois=0"; 
  $.ajax({ 
    type: "GET", 
    dataType: "jsonp", 
    url: url, 
      beforeSend: function(){ 
       
		console.log('正在定位...');
      }, 
      success: function (json) { 
        if(json.status==0){ 
         // $("#baidu_geo").html(json.result.formatted_address); 
		 // alert(json.result.addressComponent.city);
		 $("#cityy").html(json.result.addressComponent.city);
        } 
      }, 
      error: function (XMLHttpRequest, textStatus, errorThrown) { 
        $("#baidu_geo").html(latlon+"地址位置获取失败"); 
    } 
  });
				
        }  
    </script> 
	
 <script>
          $('#sheng').change(function(){
            var pcode=$(this).val();
            $.ajax({
                //取消异步，也就是必须完成上面才能走下 
                async:false,           
                url:'xianzhifl.php',
                data:{pcode:pcode},
                type:'POST',
                dataType:'text',
                success: function(res){
                    console.log(res);
                  var str="";
                  console.log(str);
                  //遍历数组，把它放入sj                 
                  var data=eval(res);
                  for(var k in data){
                    console.log(data[k][0]);
                   str += '<option value="'+data[k][0]+'">'+data[k][1]+'</option>';
                  }
                   $('#shi').empty();
                    $('#qu').empty();
                  $('#shi').append('<option value="0">二级分类</option>'+str);
                },
                error:function(res){
                    console.log("你出错了第一个、。");
                }       
              });
        });
          
           
          
   
   
</script> 
<!-- 多图上传 开始 -->
<script type="text/javascript">
$(document).ready(function(){
    //响应文件添加成功事件
    $("#inputfile").change(function(){
        //创建FormData对象
        var data = new FormData();
        //为FormData对象添加数据
        $.each($('#inputfile')[0].files, function(i, file) {
            data.append('upload_file'+i, file);
        });
         layer.open({
    type: 2
    ,content: '上传中...'
  }); //显示加载图片
        //发送数据
        $.ajax({
            url:'submit_form_process.php',
            type:'POST',
            data:data,
            cache: false,
            contentType: false,     //不可缺参数
            processData: false,     //不可缺参数
            success:function(data){
                data = $(data).html();
                //alert(data);
                //第一个feedback数据直接append，其他的用before第1个（ .eq(0).before() ）放至最前面。
                //data.replace(/&lt;/g,'<').replace(/&gt;/g,'>') 转换html标签，否则图片无法显示。
                if($("#feedback").children('img').length == 0) $("#feedback").append(data.replace(/&lt;/g,'<').replace(/&gt;/g,'>'));
                else $("#feedback").children('img').eq(0).before(data.replace(/&lt;/g,'<').replace(/&gt;/g,'>'));
				layer.closeAll();
                layer.open({
    content: '上传成功！'
    ,skin: 'msg'
    ,time: 2 //2秒后自动关闭
  });   //加载成功移除加载图片
            },
            error:function(){
                alert('上传出错');
                $(".loading").hide();   //加载失败移除加载图片
            }
        });
    });
});
</script>
<script type="text/javascript">
    function clicimg(){
        var legth=document.getElementsByName('thissrc');
        var srca="";
        for(var i=0;i<legth.length;i++){
            srca+=legth[i].src;
            srca+=",";
        }
        document.getElementById('srcall').value=srca;
        
	  var ggunit='<?=$_COOKIE['userid']?>';
	var agentprice= srca;
	var chtitle= document.getElementById("chtitle").value;
	var enbrand= document.getElementById("ziwop").value;
	var lat= document.getElementById("lat").value;
	var lng= document.getElementById("lng").value;
	var zswprice= document.getElementById("thegujia").value;
	var typeid= document.getElementById("sheng").value;	
	var entitle= document.getElementById("shi").value;	
	var diy_delivery_money= document.getElementById("diy_delivery_money").value;		
	console.log(ggunit);
	console.log(agentprice);
	console.log(chtitle);
	console.log(enbrand);
	console.log(lat);
	console.log(lng);
	console.log(zswprice);
	console.log(typeid);
	console.log(entitle);
	
		if(ggunit==""){
	layer.open({
    content: '请先登录'
    ,skin: 'msg'
    ,time: 2 
  });
 	return false; 
	}
	
	
		if(chtitle==""){
	layer.open({
    content: '请填写标题'
    ,skin: 'msg'
    ,time: 2 
  });
 	return false; 
	}	
	
			if(typeid==""){
	layer.open({
    content: '请选择分类'
    ,skin: 'msg'
    ,time: 2 
  });
 	return false; 
	}
	
			if(enbrand==""){
	layer.open({
    content: '请输入内容'
    ,skin: 'msg'
    ,time: 2 
  });
 	return false; 
	}	
	
				if(agentprice==""){
	layer.open({
    content: '请上传照片'
    ,skin: 'msg'
    ,time: 2 
  });
 	return false; 
	}
				if(zswprice==""){
	layer.open({
    content: '请输入价格'
    ,skin: 'msg'
    ,time: 2 
  });
 	return false; 
	}	
	
  
  				if(diy_delivery_money==""){
	layer.open({
    content: '请输入运费'
    ,skin: 'msg'
    ,time: 2 
  });
 	return false; 
	}
	
                                $.ajax({
                                        url: '/api/muyin/api.php?s=xianzhi.add_xianzhi_goods',
                                        type: 'POST',
                                        dataType: 'json',
                                        data: {ggunit: ggunit,
										chtitle:chtitle,
										typeid:typeid,
										entitle:entitle,
										enbrand:enbrand,
										agentprice:agentprice,
										zswprice:zswprice,
										diy_delivery_money:diy_delivery_money,
										lat:lat,
										lng:lng														
										},
                                      })
									  
                                      .done(function(respon) {
                                        if (respon.code==0) {
                                       layer.open({
                                       content: '发布成功'
                                      ,btn: ['知道了']
                                      ,yes: function(index){
                                      window.location.href="index.php";
                                     layer.close(index);
                                        }
                                        });
                                      
									  
                                        }else{
                                             layer.open({
    content: '请先输入完成后再提交！'
    ,skin: 'msg'
    ,time: 2 //2秒后自动关闭
  }); 
                                        
                                        }
                                      })

    }
  
	
	

</script>
<!-- 分类选择结束 -->
  <script type="text/javascript">
        H.on(H.Ds(".H-accordion-title"), "touchend", function (event) {
            var area = H.getParents(event.target, "H-accordion-area");
            var title = H.D(".H-accordion-title", area);
            var main = H.D(".H-accordion-main", area);
            var icon = H.D(".H-accordion-icon", area);
            if (H.isElement(main)) {
                if (H.hasClass(main, "H-display-none-important")) {

                    H.removeClass(icon, "H-icon-arrow-down");
                    H.addClass(icon, "H-icon-arrow-up");

                    H.removeClass(title, "H-theme-background-color-white");
                    H.addClass(title, "H-theme-background-color-f4f4f4");

                    H.removeClass(main, "H-display-none-important");
                }
                else {
                    H.removeClass(icon, "H-icon-arrow-up");
                    H.addClass(icon, "H-icon-arrow-down");

                    H.removeClass(title, "H-theme-background-color-f4f4f4");
                    H.addClass(title, "H-theme-background-color-white");

                    H.addClass(main, "H-display-none-important");
                }
            }
        });
    </script>
	
	<script>
	
	function del(c){
		console.log(c);
		
	  layer.open({
    content: '确定要删除当前照片吗？'
    ,btn: ['要', '不要']
    ,yes: function(index){
 
     $("#"+c).remove();
      layer.close(index);
    }
  });	
		
		

		
	}
	
	</script>
	
</body>
</html>